package com.aaa.controller.sas;

import cn.hutool.core.util.ObjectUtil;
import com.aaa.aspect.LogMonitor;
import com.aaa.controller.BaseController;
import com.aaa.entity.PageSortEntity;
import com.aaa.entity.Result;

import com.aaa.entity.sas.TestResultSas;
import com.aaa.entity.sas.ViewTestResultSas;
import com.aaa.service.sas.ViewTestResultSasService;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import java.util.Map;

/**
 * @author ：马明钢
 * @date ：Created in 2022/9/5 20:13
 * @description：
 * @modified By：
 * @version:
 */
@Controller
@RequestMapping("/viewTestResult")
public class ViewTestResultSasController extends BaseController {
    @Autowired
    ViewTestResultSasService viewTestResultSasService;

    @ResponseBody
    @RequestMapping("/queryAll.do")
    public Result queryAll(PageSortEntity page, ViewTestResultSas vs) {
        Page page1 = viewTestResultSasService.queryAll(page, vs);
        return success(page1.getResult(), page1.getTotal());
    }

    @LogMonitor
    @ResponseBody
    @RequestMapping("/delete.do")
    public Result queryAll(String id) {
        boolean delete = viewTestResultSasService.delete(id);
        if (delete) {
            return success();
        }
        return fail();
    }

    @ResponseBody
    @RequestMapping("/queryResultById.do")
    public Result queryResultById(Integer id) {
        ViewTestResultSas vs = viewTestResultSasService.queryResultById(id);
        if (ObjectUtil.isNotEmpty(vs)) {
            return success(vs);
        }
        return fail();
    }

    @ResponseBody
    @RequestMapping("/queryAllPlan.do")
    public Result queryAllPlan() {
        Map<String, Integer> map = viewTestResultSasService.queryAllPlanSas();
        if (ObjectUtil.isNotEmpty(map)) {
            return success(map);
        }
        return fail();
    }

    /**
     *  * @create by: 马明钢 
     *
     * @param id 
     * @return com.aaa.entity.Result 
     * @description:  查询个人答题详情
     * @create time: 2022/9/9 10:57 * @param page
     */
    @ResponseBody
    @RequestMapping("/selectAllByPerson.do")
    public Result selectAllByPerson(PageSortEntity page, TestResultSas id) {
        Page viewPersonResultSas = viewTestResultSasService.selectAllByPerson(page,id);
        return success(viewPersonResultSas.getResult(), viewPersonResultSas.getTotal());
    }


}
